package com.kaifamiao.object;

import java.io.Serializable;

// 对象序列化:
//    (1)、通过实现 Serializable 接口来实现对象序列化 (仅提供 serialVersionUID 即可)
//         若未实现 Serializable 接口则在序列化时会抛出 NotSerializableException
//    (2)、通过实现 Externalizable 接口实现对象序列化 (实现抽象方法)
//    (3)、自定义序列化
public class Panda implements Serializable {

    private static final long serialVersionUID = 735144970007477205L;

    private int id;
    private String name;
    private char gender;
    // 被 transient 修饰的字段不会被序列化
    private transient short age;

    public Panda(int id, String name, char gender) {
        this.id = id;
        this.name = name;
        this.gender = gender;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public short getAge() {
        return age;
    }

    public void setAge(short age) {
        this.age = age;
    }
}
